<?php
/**
 * Template Name: News
 *
 * A custom page template for news page.
 *
 * The "Template Name:" bit above allows this to be selectable
 * from a dropdown menu on the edit page screen.
 *
 * @package WordPress
 * @subpackage MIP
 * @since MIP 1
 */

get_header(); ?>

	<?php if(!is_front_page()){ ?>
	<div id="header_inner">
		<div id="headertext">
			 <?php  include_once (TEMPLATEPATH . '/title.php'); ?>
		</div>
	</div>
	<?php } ?>	
 
	<!-- BEGIN CONTENT -->
	<div id="container_content">
	<div id="padding_content">
		<div id="maincontent">
			<?php if ( function_exists('yoast_breadcrumb') && !is_front_page() ) {
			yoast_breadcrumb('<div id="breadcrumbs">','</div>');
			} ?>

			<?php 
			if ( is_active_sidebar('before-content') ) {
			get_sidebar('before-content');
			}
			?>
			<div id="main">
				<div id="content">

					<?php $values = get_post_custom_values("category-include"); $cat=$values[0];  ?>
					<?php $thumbs = get_post_custom_values("thumb"); $thumb=$values[0];  ?>
					<?php $strinclude = $cat;?>
					<?php $catinclude = 'category_name=' . $strinclude ;?>
					<?php query_posts('&' . $catinclude .' &paged='.$paged. '&showposts=5'); ?>
									
					<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
					
					
					<?php
						$custom = get_post_custom($post->ID);
						
						if($thumb!=""){
							$thumb = "<img src='" . $thumb . "' alt='' width='72' height='72' />";
						}
					?>
			
            	<div class="box-news">
                    <?php if($thumb!=""){ echo $thumb; }else{ the_post_thumbnail( );} ?>
					<div class="news-txt">
                    <h2><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
                    <span class="postdate"><?php  the_time('l, F j, Y') ?></span>
					<p><?php $excerpt = get_the_excerpt(); echo ts_string_limit_words($excerpt,20);?></p>
					</div>               	
                </div><!-- end box-news-->

			<?php endwhile; ?>
			
			
		<?php if (  $wp_query->max_num_pages > 1 ) : ?>
	
		<?php if(function_exists('wp_pagenavi')) { ?>
				 <?php wp_pagenavi(); ?>
		<?php }else{ ?>
				<div id="nav-below" class="navigation nav2">
					<div class="nav-previous"><?php next_posts_link( __( '<span class="prev"><span class="meta-nav">&laquo;</span> Prev</span>' ) ); ?></div>
					<div class="nav-next"><?php previous_posts_link( __( '<span class="prev">Next <span class="meta-nav">&raquo;</span></span>' ) ); ?></div>
				</div><!-- #nav-below -->
		<?php }?>
		<?php endif; ?>
		
		<?php wp_reset_query();?>		
				</div><!-- end of content -->
			</div><!-- end of main -->
			<div id="side">
				<?php get_sidebar('page'); ?>
			</div><!-- end of side -->
		</div><!-- end of maincontent -->
	</div>
	<div class="clr"></div>
	</div>
	<!-- END OF CONTENT -->
	
	</div><!-- end of centercolumn -->
</div><!-- end of main container -->
<?php get_footer(); ?>
